<?php
// +---------------------------------------------------------------------------+
// | This file is part of the KnowledgebasePublisher package                   |
// | KnowledgebasePublisher - web based knowledgebase publisher tool           |
// |                                                                           |
// | Author:  Evgeny Leontev <eleontev@gmail.com>                              |
// | Copyright (c) 2005 Evgeny Leontev                                         |
// |                                                                           |
// | For the full copyright and license information, please view the LICENSE   |
// | file that was distributed with this source code.                          |
// +---------------------------------------------------------------------------+

class Feedback extends AppObj
{
	
	var $properties = array('id'		 	=> NULL,
							'user_id'		=> '',
							'admin_id'		=> '',
							'category_id'	=> '',
							'name'	 		=> '',
							'email'	 		=> '',
							'question'	 	=> '',
							'attachment'	=> '',
							'answer' 		=> '',
							'date_posted'	=> '',
							'date_answered'	=> '',
							'answered'		=> 0,
							'placed'		=> 0
							);
	
	var $hidden = array('id', 'admin_id', 'user_id', 'date_posted', 
	                    'category_id', 'name', 'email', 'question', 'attachment');
	
	
	function _callBack($property, $val) {
		if($property == 'date_answered' && !$val) {
			$val = date('Y-m-d H:i:s');
		} elseif($property == 'admin_id' && !$val) {
			$val = $_SESSION['member_']['user_id'];
		}
		
		return $val;
	}
	
	
	function validate($values) {
		
		require_once 'eleontev/Validator.php';
		
		$required = array('answer');
		
		$v =& new Validator($values, false);

		// check for required first, return errors
		$v->requiredArray('required_msg', $required);
		if($v->getErrors()) {
			$this->errors =& $v->getErrors();
			return true;
		}
	}
}
?>